package com.database.daos.imp;

import java.util.List;

import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.database.daos.IGenericDao;

public abstract class GenericDao<T> extends HibernateTemplate implements IGenericDao<T> {

	private static final long serialVersionUID = -5861059323822702894L;

	@Override
	@Transactional(propagation = Propagation.REQUIRES_NEW)
	public void saveElement(T object) {
		if (object != null) {
			saveOrUpdate(object);
		}
	}

	@Override
	@Transactional(propagation = Propagation.REQUIRES_NEW)
	public void saveAll(List<T> objects) {
		saveOrUpdateAll(objects);
	}

	@Override
	@Transactional(propagation = Propagation.REQUIRES_NEW)
	public void deleteElement(T object) {
		delete(object);
	}

}